import os
import configparser
from config.const import constant
from utils.log import log_api


def load_all_messages():
    from config import server_config
    log_api.info('开始加载错误消息')

    config = configparser.RawConfigParser()
    path = os.path.join(os.path.dirname(__file__), os.pardir)
    path = os.path.join(path, 'config')
    path = os.path.join(path, 'const')
    path = os.path.join(path, 'error_msg.properties')
    config.read(path, encoding=constant.ENCODING_UTF8)
    for key, value in config.items('code_msgs'):
        server_config.error_messages[int(key)] = value

    log_api.info('结束加载错误消息')
